package cqrtplm.controller;

import com.alibaba.fastjson.JSONObject;
import cqrtplm.service.RTCDecryptionService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ty.basic.response.ResponseResult;

import javax.annotation.Resource;

@RestController
@RequestMapping("/rest/rtc/v1")
public class RTCDecryptionController {

    @Resource
    private RTCDecryptionService rtcDecryptionService;

    @PostMapping("/decryption")
    public ResponseResult decryption(@RequestBody String str){
        JSONObject jsonObject = JSONObject.parseObject(str);
        String projectId = jsonObject.getString("projectId");
        String type = jsonObject.getString("type");
        try {
            rtcDecryptionService.decryption(projectId,type);
        }catch (Exception e) {
            e.printStackTrace();
            return ResponseResult.fail("400",e.getMessage());
        }
        return ResponseResult.success();
    }
}
